class MyException(Exception):
    def __init__(self,msg):
        self.msg=msg

try:
    #raise引发一个自定义异常
    raise MyException("自定义异常")
except MyException as arg:
    print(arg.msg)
else:
    print("没有捕捉到异常")
finally:
    print("不管有没有异常，我都会执行")